import React, { Component } from 'react';
import { UserContext } from '../context/user-context';

//没有被Context.Provider包裹，使用默认的context
class Profile extends Component {
  constructor(props) {
    super(props);
  }
  render() { 
    const {nickName, age} = this.context;
    return ( 
      <div>
        <h2>Profile</h2>
        <p>{nickName} - {age}</p>
      </div>
     );
  }
}

Profile.contextType = UserContext
 
export default Profile;